package emp.jsf.servicio.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import emp.entidades.EntBanco;
import emp.jsf.servicio.BancoService;
import emp.repositorios.BancoRepository;

@Service("bancoService")
public class BancoServiceImpl implements BancoService{

	@Autowired
	BancoRepository bancoRepository;
	
	@Override
	@Transactional
	public List<EntBanco> listarBancos(){
		List<EntBanco> lista;
		lista=bancoRepository.findAll();
		
		for(EntBanco l:lista){
			l.getEntEmpresa().getRazonSocial();
		}
		
		return lista;
	}
	
	public EntBanco grabarBanco(EntBanco ent){
		ent.setEstado(1);
		return bancoRepository.save(ent);
	}
	
	public EntBanco actualizarBanco(EntBanco ent){
		return bancoRepository.save(ent);
	}
	
	
	public void eliminar(String id){
		EntBanco ent=bancoRepository.findOne(Long.valueOf(id));
		bancoRepository.delete(ent);
	}
	
}
